/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package SuperMarket_package;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author user
 */
@Entity
@Table(name = "CREDIT_CARD")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CreditCard.findAll", query = "SELECT c FROM CreditCard c"),
    @NamedQuery(name = "CreditCard.findByCardId", query = "SELECT c FROM CreditCard c WHERE c.cardId = :cardId"),
    @NamedQuery(name = "CreditCard.findByCvv", query = "SELECT c FROM CreditCard c WHERE c.cvv = :cvv"),
    @NamedQuery(name = "CreditCard.findByNumber", query = "SELECT c FROM CreditCard c WHERE c.number = :number"),
    @NamedQuery(name = "CreditCard.findByOwner", query = "SELECT c FROM CreditCard c WHERE c.owner = :owner"),
    @NamedQuery(name = "CreditCard.findByBank", query = "SELECT c FROM CreditCard c WHERE c.bank = :bank"),
    @NamedQuery(name = "CreditCard.findByCustId", query = "SELECT c FROM CreditCard c WHERE c.custId = :custId")})
public class CreditCard implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "CARD_ID")
    private Integer cardId;
    @Basic(optional = false)
    @Column(name = "CVV")
    private String cvv;
    @Basic(optional = false)
    @Column(name = "NUMBER")
    private String number;
    @Basic(optional = false)
    @Column(name = "OWNER")
    private String owner;
    @Basic(optional = false)
    @Column(name = "BANK")
    private int bank;
    @Basic(optional = false)
    @Column(name = "CUST_ID")
    private int custId;

    public CreditCard() {
    }

    public CreditCard(Integer cardId) {
        this.cardId = cardId;
    }

    public CreditCard(Integer cardId, String cvv, String number, String owner, int bank, int custId) {
        this.cardId = cardId;
        this.cvv = cvv;
        this.number = number;
        this.owner = owner;
        this.bank = bank;
        this.custId = custId;
    }
public CreditCard(Integer cardId,Integer bank,  String owner,String number,String cvv ) {
        this.cardId = cardId;
        this.bank = bank;
        this.owner = owner;
         this.number = number;
        this.cvv = cvv;                    
    }
    public Integer getCardId() {
        return cardId;
    }

    public void setCardId(Integer cardId) {
        Integer oldCardId = this.cardId;
        this.cardId = cardId;
        changeSupport.firePropertyChange("cardId", oldCardId, cardId);
    }

    public String getCvv() {
        return cvv;
    }

    public void setCvv(String cvv) {
        String oldCvv = this.cvv;
        this.cvv = cvv;
        changeSupport.firePropertyChange("cvv", oldCvv, cvv);
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        String oldNumber = this.number;
        this.number = number;
        changeSupport.firePropertyChange("number", oldNumber, number);
    }

    public String getOwner() {
        return owner;
    }

    public void setOwner(String owner) {
        String oldOwner = this.owner;
        this.owner = owner;
        changeSupport.firePropertyChange("owner", oldOwner, owner);
    }

    public int getBank() {
        return bank;
    }

    public void setBank(int bank) {
        int oldBank = this.bank;
        this.bank = bank;
        changeSupport.firePropertyChange("bank", oldBank, bank);
    }

    public int getCustId() {
        return custId;
    }

    public void setCustId(int custId) {
        int oldCustId = this.custId;
        this.custId = custId;
        changeSupport.firePropertyChange("custId", oldCustId, custId);
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (cardId != null ? cardId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CreditCard)) {
            return false;
        }
        CreditCard other = (CreditCard) object;
        if ((this.cardId == null && other.cardId != null) || (this.cardId != null && !this.cardId.equals(other.cardId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "SuperMarket_package.CreditCard[ cardId=" + cardId + " ]";
    }

    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
